﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CRM.Database.Model.Customers>" %>
<%@ Import Namespace="CRM.Database.Model" %>
<%@ Import Namespace="CRM.Resourses" %>

<% Html.DevExpress().GridView(settings =>
                    {
                        settings.Name = "gdEquipment";
                        settings.KeyFieldName = "IdCustomersEquipments";

                        settings.CallbackRouteValues =
                                           new { Controller = "Customers", Action = "CustomerEquipments", customerId=Model.IdCustomer};
                        settings.SettingsPager.PageSize = 20;

                        settings.Settings.ShowGroupPanel = true;
                        settings.Settings.ShowFilterRow = true;
                        
                        
                       settings.Columns.Add(column =>
                        {
                            column.FieldName = "Equipments.IdEquipmentType";
                            column.Caption = Resourses.EquipmentType;
                            column.ColumnType = MVCxGridViewColumnType.ComboBox;

                            var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                            if (comboBoxProperties != null)
                            {
                                var col = new EquipmentTypesCollection();
                                comboBoxProperties.DataSource = col.EquipmentTypesList;

                                comboBoxProperties.TextField = "LocalizedName";
                                comboBoxProperties.ValueField = "IdEquipmentType";
                                comboBoxProperties.ValueType = typeof(int);
                            }
                        });
                        
                         
                       
                        settings.Columns.Add(column =>
                        {
                            column.FieldName = "Equipments.IdVendor";
                            column.Caption = Resourses.EquipmentVendor;
                            column.ColumnType = MVCxGridViewColumnType.ComboBox;

                            var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                            if (comboBoxProperties != null)
                            {
                                var col = new VendorsCollection();
                                comboBoxProperties.DataSource = col.VendorsList;

                                comboBoxProperties.TextField = "VendorName";
                                comboBoxProperties.ValueField = "IdVendor";
                                comboBoxProperties.ValueType = typeof(int);
                            }
                        });
                        
                        
                      
                        settings.Columns.Add(column =>
                        {
                            column.Caption = Resourses.EquipmentModel;
                            column.FieldName = "Equipments.Model";
                        });
                        settings.Columns.Add(column =>
                        {
                            column.Caption = Resourses.EquipmentProductionDate;
                            column.ColumnType = MVCxGridViewColumnType.DateEdit;
                            column.FieldName = "IssueDate";
                        });
                        settings.Columns.Add(column =>
                        {
                            column.Caption = Resourses.EquipmentCount;
                            column.FieldName = "EquipmentCount";
                        });
                                       
                    }

    ).Bind(Model.CustomersEquipments.ToList()).GetHtml();                 %>